const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
+const GnomeDesktop = imports.gi.GnomeDesktop;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Signals = imports.signals;
// the slide up automatically
const ARROW_DRAG_TRESHOLD = 0.4;
+const Clock = new Lang.Class({
+ Name: 'ScreenShieldClock',
+
+ CLOCK_FORMAT_KEY: 'clock-format',
+ CLOCK_SHOW_SECONDS_KEY: 'clock-show-seconds',
+
+ _init: function() {
+ this.actor = new St.BoxLayout({ style_class: 'screen-shield-clock',
+ vertical: true });
+
+ this._time = new St.Label({ style_class: 'screen-shield-clock-time' });
+ this._date = new St.Label({ style_class: 'screen-shield-clock-date' });
+
+ this.actor.add(this._time, { x_align: St.Align.MIDDLE });
+ this.actor.add(this._date, { x_align: St.Align.MIDDLE });
+
+ this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
+ this._wallClock.connect('notify::clock', Lang.bind(this, this._updateClock));
+
+ this._updateClock();
+ },
+
+ _updateClock: function() {
+ this._time.text = this._wallClock.clock;
+
+ let date = new Date();
+ /* Translators: This is a time format for a date in
+ long format */
+ this._date.text = date.toLocaleFormat(_("%A, %B %d"));
+ },
+
+ destroy: function() {
+ this.actor.destroy();
+ this._wallClock.run_dispose();
+ }
+});
+
/**
* To test screen shield, make sure to kill gnome-screensaver.
*
this._isModal = false;
this._isLocked = false;
+ this._hasLockScreen = false;
this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
{ inhibitEvents: true, fadeInTime: 10, fadeFactor: 1 });
this._lockScreenGroup.grab_key_focus();
},
+ // Some of the actors in the lock screen are heavy in
+ // resources, so we only create them when needed
+ _prepareLockScreen: function() {
+ this._lockScreenContentsBox = new St.BoxLayout({ x_align: Clutter.ActorAlign.CENTER,
+ y_align: Clutter.ActorAlign.CENTER,
+ x_expand: true,
+ y_expand: true,
+ vertical: true });
+ this._clock = new Clock();
+ this._lockScreenContentsBox.add(this._clock.actor, { x_fill: true,
+ y_fill: true });
+
+ this._lockScreenGroup.add_actor(this._lockScreenContentsBox);
+
+ this._hasLockScreen = true;
+ },
+
+ _clearLockScreen: function() {
+ this._clock.destroy();
+ this._clock = null;
+
+ this._lockScreenContentsBox.destroy();
+
+ this._hasLockScreen = false;
+ },
+
get locked() {
return this._isLocked;
},
unlock: function() {
+ if (this._hasLockScreen)
+ this._clearLockScreen();
+
if (this._keepDialog) {
// The dialog must be kept alive,
// so immediately go back to it
},
lock: function() {
+ if (!this._hasLockScreen)
+ this._prepareLockScreen();
+
if (!this._isModal) {
Main.pushModal(this.actor);
this._isModal = true;